package com.haoze.nurseapp.controller;

import com.haoze.common.response.Result;
import com.haoze.nurseapp.model.UserEntity;
import com.haoze.nurseapp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author embed
 */
@RestController
@RequestMapping("/nurseapp/user")
@Api(value = "护理app端")
@Validated
public class UserController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public Result login(@RequestBody final UserEntity user) {

        return userService.login(user);
    }

    @GetMapping("/userInfo")
    @ApiOperation(value = "获取用户信息")
    public Result getFormListByUser(@RequestParam final String account) {
        return userService.getUserInfo(account);
    }

    @GetMapping("/rememberClinetId")
    @ApiOperation(value = "记录用户的clientId")
    public Result rememberClinetId(@RequestParam final String account,@RequestParam final String clientId) {
        return userService.updateClinetIdByAccount(account, clientId);
    }

}
